<template>
  <div class="header">
    <div @click="$router.push('/home')"><img src="../assets/logo.png" alt="" /></div>

    <div @click="$router.push('/search')">
      <van-icon name="search" class="search" />
      点击搜索
      </div>

    <div>
      <img :src="headimg" alt="" @click="$router.push('/user')" />
      <div>
        <p>下载App</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      headimg: '../assets/aa.jpg'
    }
  },
  created() {
    this.getUserData()
  },
  methods:{
      async getUserData() {
      const res = await this.$http.get(`/user/${localStorage.getItem("id")}`)
      this.headimg = res.data[0].user_img
      // console.log(this.headimg);
    }
  }
};
</script>

<style lang="less" scoped>
.header {
  height: 45px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fff;
  div:nth-child(1) {
    width: 100px;
    height: 25px;
    margin-left: 5px;
    margin-top: -10px;
    img {
      width: 80px;
    }
  }
  div:nth-child(2) {
    flex: 1;
    background-color: #e7e7e7;
    margin: 0 4.167vw 0 0;
    border-radius: 2.778vw;
    position: relative;
    width: 20.833vw;
    font-size: 3.611vw;
    text-align: center;
    vertical-align: middle;
    // .p{
    //   margin: -19px  0 0 8.333vw;
    //   position: absolute;
    //   text-align: center;
    //   height: 6.389vw;
    //   font-size: 3.611vw;
    // }
    .search{
      margin-left: 2px;
      margin-top: 3px;
    }
  }
  div:nth-child(3) {
    display: flex;
    justify-content: center;
    align-items: center;
    img {
      width: 24px;
      height: 24px;
      border-radius: 12px;
    }
    div {
      margin-left: 8px;
      background-color: #ffa9b5;
      height: 25px;
      width: 75px;
      border-radius: 3px;
      p {
        padding: 0 10px;
        margin: 4px 3px;
        font-size: 12px;
        color: #fff;
      }
    }
  }
}
</style>
